from selenium.webdriver import Chrome, ChromeOptions
from selenium import webdriver
import schedule
import time
def tiwen():
    # opt = ChromeOptions()  # 创建Chrome参数对象
    # opt.headless = True  # 把Chrome设置成可视化无界面模式，windows/Linux 皆可
    # driver = Chrome(options=opt)  # 创建Chrome无界面对象

    # driver = webdriver.Chrome(chrome_options=chrome_options,executable_path = '/www/wwwroot/chromedriver_linux64')#放linux服务器

    #1.创建Chrome浏览器对象，这会在电脑上在打开一个浏览器窗口
    driver = webdriver.Chrome(executable_path =r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\chromedriver")
    # driver.maximize_window()

    driver.get('https://cas.sues.edu.cn/cas/login?service=https%3A%2F%2Fweb-vpn.sues.edu.cn%2Flogin%3Fcas_login%3Dtrue')

    driver.find_element_by_id('username').send_keys('你的账号')#输入账号
    driver.find_element_by_id('password').send_keys('你的密码')#输入密码

    denglu=driver.find_element_by_name('submit')
    denglu.click()#点击登录
    driver.back()#跳转

    time.sleep(2)
    jiankang=driver.find_element_by_class_name('vpn-content-block-panel__url')
    jiankang.click()

    driver.get('https://web-vpn.sues.edu.cn/https/77726476706e69737468656265737421f3f652d234256d43300d8db9d6562d/cas/login?service=https%3A%2F%2Fworkflow.sues.edu.cn%2Fdefault%2Fwork%2Fshgcd%2Fjkxxcj%2Fjkxxcj.jsp')
    driver.find_element_by_id('username').send_keys('051719220')#输入账号
    driver.find_element_by_id('password').send_keys('Zxcvbnm123')#输入密码
    deng=driver.find_element_by_name('submit')
    deng.click()#点击登录

    driver.get('https://web-vpn.sues.edu.cn/https/77726476706e69737468656265737421e7f85397213c6747301b9ca98b1b26312700d3d1/default/work/shgcd/jkxxcj/jkxxcj.jsp')
    time.sleep(1)
    for e in driver.find_elements_by_class_name('form-control'):
        if e.get_attribute('placeholder') == "范围35.0-45.0":
            e.send_keys('36.1')
            break
    time.sleep(1)
    driver.find_element_by_id('post').click()
    print('体温填报成功')
    # driver.quit()#温度填好了就关闭

def loop_func(func, miao):
 #每隔second秒执行func函数
    while True:
        func()
        time.sleep(miao)
loop_func(tiwen,10000)
